<?php

$api = app('Dingo\Api\Routing\Router');
$moduleName = 'Agent';

// 平台后台api
$api->version('v1', ['prefix' => 'admin-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Admin\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'] ;

	$api->get('/status-total/brokerage', ['uses'=> "BrokerageController@statusTotal"]);
	$api->get('agent/brokerages', ['uses'=> "BrokerageController@index"]);

	$api->get('/status-total/invite-record', ['uses'=> "InviteRecordController@statusTotal"]);
	$api->get('agent/invite-records', ['uses'=> "InviteRecordController@index"]);

	// 佣金设置
	$api->get('/agent/setting/brokerage', ['uses' => "SettingController@getBrokerage"]);
	$api->put('/agent/setting/brokerage', ['uses' => "SettingController@setBrokerage"]);

	$api->get('/status-total/agent', ['uses'=> "AgentController@statusTotal"]);

	// 分销员
	// $api->get('/agent-levels', ['uses' => "AgentLevelController@index"]);
	
	$api->resource('agent-levels', "AgentLevelController", ['only' => $allMethod]);
	$api->get('/agents', ['uses' => "AgentController@index"]);
	$api->patch('/agents/{uuid}', ['uses' => "AgentController@update"]);

	$api->post('/export/agent', ['uses'=> "AgentExportController@store"]);
	$api->post('/export/agent/total', ['uses'=> "AgentExportController@total"]);
	$api->get('/export/agent/{uuid}', ['uses'=> "AgentExportController@show"]);

	$api->post('/export/brokerage', ['uses'=> "BrokerageExportController@store"]);
	$api->post('/export/brokerage/total', ['uses'=> "BrokerageExportController@total"]);
	$api->get('/export/brokerage/{uuid}', ['uses'=> "BrokerageExportController@show"]);
});

// 租户api
// $api->version('v1', ['prefix' => 'tenant-api', 'namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Tenant\V1'], function ($api) {
// 	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
// });

// 普通用户api
$api->version('v1', ['namespace' => 'Modules\\'.$moduleName.'\Http\Controllers\Client\V1'], function ($api) {
	$allMethod = ['index', 'show', 'store', 'update', 'destroy'];
	
	$api->get('/agent/setting', ['uses' => "SettingController@show"]);

	// 获取我邀请的人
	$api->get('user/invitees', ['uses'=> "InviteeController@index"]);
	
	// 我的佣金统计
	$api->get('agent/brokerage', ['uses'=> "BrokerageController@detail"]);
	// 我的佣金列表
	$api->get('agent/brokerages', ['uses'=> "BrokerageController@index"]);
});